package com.hhh.petadopt.serviceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hhh.petadopt.mapper.FoundPetMapper;
import com.hhh.petadopt.pojo.PetFound;
import com.hhh.petadopt.service.FoundPetService;
import com.hhh.petadopt.utils.IDUtils;
/**
 * 发现流浪动物处理
 * @author 杜镇声声
 *
 */
@Service
public class FoundPetServiceImpl implements FoundPetService {

	@Autowired
	private FoundPetMapper foundPetMapper;
	@Override
	public void saveFound(PetFound foundd) {
		//补全信息
		//id
		long ids = IDUtils.genItemId();
		String id = String.valueOf(ids).substring(6);
		foundd.setId(Long.valueOf(id));
		
		//isaccept 是否受理,1表示受理,2表示不受理,默认是2
		foundd.setIsaccept("2");
		//将string格式的时间转换为date
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");
		Date date=new Date();
		String dateStr = sdf.format(date);
		try {
			Date mydate = sdf.parse(dateStr);
			foundd.setFtimee(mydate);
			
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		foundd.setCreatedd(new Date());
		foundd.setUpdated(new Date());
		
		//执行操作
		foundPetMapper.saveFound(foundd);

	}

}
